!!! Strict
%html{:lang => "en", :xmlns => "http://www.w3.org/1999/xhtml"}
  %head
    %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
    %title=@title || "GRC"
    %meta{:name => "viewport", :content => "width=device-width", :'initial-scale' => "1.0"}

    :javascript
      window.currentUser = #{current_user.to_json(:root => false, :except => [:crypted_password, :persistence_token], :methods => [:'can_admin?', :'can_manage_risk?'])}
    -if has_feature? :BETA
      =stylesheet_link_tag 'design'
      =javascript_include_tag 'design'
      -#
        %meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}/
        %meta{:content => "", :name => "description"}/
        %meta{:content => "", :name => "author"}/
        / The HTML5 shim, for IE6-8 support of HTML5 elements
        /[if lt IE 9] <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    -else
      =stylesheet_link_tag 'dashboard'
      =javascript_include_tag 'dashboard'
    =csrf_meta_tag
    %link(href='/favicon.ico' rel='icon' type='image/x-icon')

    -#NOTE: This resource occasionally hangs and prevents page from rendering, so loaded after the fact via jquery
    :javascript
      jQuery(function($) { $('head').append("<link href='https://fonts.googleapis.com/css?family=Titillium+Web' rel='stylesheet' type='text/css'></link>"); });


  %body{ page_type_attributes, :class => "#{has_feature?(:BETA) ? 'BETA' : ''}", :'data-target' => '.bs-docs-sidebar', :'data-spy' => 'scroll'}

    %header.header.main
      .header-bar
        .container-fluid
          .row-fluid
            .span12
              .logo.pull-left
                %a{:href => root_path}
                  -if CMS_CONFIG["COMPANY_LOGO"].present?
                    =image_tag(CMS_CONFIG['COMPANY_LOGO'], :alt => 'GRC', :title => 'GRC')
                  -elsif CMS_CONFIG["COMPANY_LOGO_TEXT"].present?
                    =CMS_CONFIG["COMPANY_LOGO_TEXT"]
                  -else
                    Google GRC
              %ul.menu
                %li.quick-search
                  .quick-search-holder
                    %button(type='submit')
                      %i.grcicon-search-white
                    %input.ui-corner-all.widgetsearch.clear-value(type='text' placeholder='Type to Search / Create')
                  .quick-search-results
                    %a.remove{:href => "#", :class => "btn btn-mini pull-right", :rel => "tooltip", :title => "Hide", :'data-placement'=>"left"}
                      %i.grcicon-x-grey
                    %p.title
                      Search Results
                      =render 'programs_dash/quick_find', :quick_result => true

                    .quick-find-add
                      Didn't find it in results?
                      .btn-group.pull-right.dropup
                        %a.btn.btn-mini.dropdown-toggle{:href => '#', :'data-toggle' => 'dropdown'}
                          %i.grcicon-add-black
                          Object
                          %i.grcicon-carot
                        %ul.dropdown-menu
                          %li.divider
                          %li.title Create New ...
                          -#if controller.respond_to?(:new_object_path) && controller.new_object_path.present?
                            %li
                              %a{ :href => controller.new_object_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                                =controller.new_object_title
                            %li.divider
                          %li
                            %a{ :href => new_flow_program_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Program
                          %li.divider
                          %li
                            %a{ :href => new_flow_directive_path(:meta_kind => :regulation), :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Regulation
                          %li
                            %a{ :href => new_flow_directive_path(:meta_kind => :contract), :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Contract
                          %li
                            %a{ :href => new_flow_directive_path(:meta_kind => :policy), :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Policy
                          %li
                            %a{ :href => new_flow_control_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Control
                          %li.divider
                          - if current_user.can_manage_risk?
                            %li
                              %a{ :href => new_flow_risky_attribute_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                                Risky Attribute
                            %li
                              %a{ :href => new_flow_risk_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                                Risk
                            %li.divider
                          %li
                            %a{ :href => new_flow_system_path(:'system[is_biz_process]' => 1), :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Process
                          %li
                            %a{ :href => new_flow_system_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              System
                          %li
                            %a{ :href => new_flow_org_group_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Org Group
                          %li
                            %a{ :href => new_flow_product_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Product
                          %li
                            %a{ :href => new_flow_project_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Project
                          %li
                            %a{ :href => new_flow_facility_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Facility
                          %li
                            %a{ :href => new_flow_market_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Market
                          %li
                            %a{ :href => new_flow_data_asset_path, :'data-toggle' => 'modal-ajax-form', :'data-modal-reset' => 'reset', :'data-form-target' => 'redirect', :'data-modal-class' => 'modal-wide' }
                              Data Asset

                -#%li.black-link
                  %a{:href => programs_dash_path}
                    %i.grcicon-dashboard
                    %span
                      Dashboard
                -help_path = yield(:page_help)
                -if !help_path.blank?
                  %li.black-link
                    %a{:href => "/help/#{help_path}", :'data-toggle' => 'modal-ajax'}
                      %i.grcicon-help
                      %span
                        Help
                %li.user.dropdown.dropdown-black.black-link
                  %a{:href => "#", :class => "dropdown-toggle", :'data-toggle' =>"dropdown", :role =>"button"}
                    %i.grcicon-user
                    %span
                      %strong=current_user.email
                    %i.grcicon-carot-white
                  %ul.dropdown-menu{:'aria-labelledby' => 'drop1', :role =>"menu"}
                    -if current_user.can_admin?
                      %li
                        %a{:href => admin_dash_path}
                          %i.grcicon-admin
                          Admin Area
                    %li
                      %a.clear-display-settings{:href =>"javascript://", :tabindex =>"-1"}
                        %i.grcicon-desktop
                        Reset Layout to Default
                    %li
                      %a.set-display-settings-default{:href =>"javascript://", :tabindex =>"-1"}
                        %i.grcicon-desktop
                        Set Layout as Default
                    %li
                      %a{:href =>logout_path, :tabindex =>"-1"}
                        %i.grcicon-logout
                        Logout
                %li.screen.dropdown.dropdown-black.black-link
                  %a{:href => "#", :class => "dropdown-toggle screen-size", :'data-toggle' =>"dropdown", :role =>"button"}
                    %i.grcicon-desktop
                    %span
                      100%
                    %i.grcicon-carot-white
                  %ul.dropdown-menu{:'aria-labelledby' => 'drop2', :role =>"menu"}
                    %li.full-view
                      %a{:href =>'#', :tabindex =>"-1"}
                        %i.grcicon-wide
                        100%
                    %li.wide-view
                      %a{:href =>'#', :tabindex =>"-1"}
                        %i.grcicon-wide
                        Wide
                    %li.narrow-view
                      %a{:href =>'#', :tabindex =>"-1"}
                        %i.grcicon-normal
                        Narrow

      .header-content{:'data-spy' => 'affix', :'data-offset-top' => '25'}
        .container-fluid
          .row-fluid
            .span5
              =yield :header
            .span7
              =yield :subheader_extras

    =yield :subheader_plus

    %section.content{:'data-spy' => 'affix', :'data-offset-top' => '25'}
      .container-fluid
        .flash
          -flash.each do |type, value|
            -value = [value] unless value.is_a?(Array)
            -value = value.map(&:presence).compact
            -if value.size > 0
              %div{ :class => type }
                %a.close{:href=>"#{}", :'data-dismiss' => "alert"}
                  &times;
                
                -value.each do |message|
                  %p=message
      =yield

    %section.footer
      .container-fluid
        .row-fluid
          .span12
            %ul.bottom-nav.pull-left
              %li
                -if controller_name == 'design'
                  -path = programs_dash_path
                -else
                  -path = request.fullpath
                -path = path.gsub(/BETA=[^&]*&?/, '').sub(/[?&]$/, '')
                -path += path.include?('?') ? '&' : '?'
                -if has_feature? :BETA
                  %a.demo-hide{ :href => "#{path}BETA=0" }
                    Hide Demo
                -else
                  %a.demo-show{ :href => "#{path}BETA=1" }
                    Show Demo
            %p
              =CMS_CONFIG['COMPANY']
              Confidential.
              Copyright &copy;
              =Time.now.year
              =CMS_CONFIG['COMPANY']
              Version #{CMS_CONFIG['CMS_APP_VERSION']}

    #templates
      #help-modal.modal.hide.fade
        .modal-header
          %a.close{"data-dismiss" => "modal"} x
          %h1 This content/function is coming soon
        .modal-body
          %p We are working on it!
        .modal-footer
          %a.close.btn.btn-large.btn-primary{"data-dismiss" => "modal", :href => "#"} Close

      #comingsoon-modal.modal.hide.fade
        .modal-header
          %a.close{"data-dismiss" => "modal"} x
          %h1 This content/function is coming soon
        .modal-body
          %p We are working on it!
        .modal-footer
          %a.close.btn.btn-large.btn-primary{"data-dismiss" => "modal", :href => "#"} Close
